<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0-alpha1/react.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0-alpha1/JSXTransformer.js"></script>
</head>
<body>
  <div id="container"></div>
  <script type="text/jsx">
    var TestClickComponent = React.createClass({
      render() {
        return (
          <div>
            <button onClick={this.handleClick}>显示|隐藏</button><span ref="tip">测试点击</span>
          </div>
        )
      },
      handleClick(event) {
        var tipE = React.findDOMNode(this.refs.tip)

        if (tipE.style.display === 'none') {
          tipE.style.display = 'inline'
        }
        else {
          tipE.style.display = 'none'
        }
        event.stopPropagation()
        event.preventDefault()
      }
    })

    var TestInputComponent = React.createClass({
      getInitialState() {
        return {
          inputContent: '',
          a: 'aaa'
        }
      },
      render() {
        console.log(this.state)
        return (
          <div>
            <input type="text" onChange={this.changeHandler} /><span>{this.state.inputContent}</span>
          </div>
        )
      },
      changeHandler(event) {
        this.setState({ inputContent: event.target.value })

        event.preventDefault()
        event.stopPropagation()
      }
    })

    React.render(
      <div>
        <TestClickComponent />
        <TestInputComponent />
      </div>
      ,document.getElementById('container')
    )
  </script>
</body>
</html>